var t = getApp();

Page({
    data: {
        id: "",
        num: 1,
        info: {},
        has_one_share: ""
    },
    onLoad: function(t) {
        t.id && this.setData({
            id: t.id
        });
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en
        }), this.getdata();
    },
    goHome: function() {
        wx.navigateTo({
            url: "/packageG/index/index"
        });
    },
    goOrder: function() {
        wx.navigateTo({
            url: "/packageA/member/myOrder_v2/myOrder_v2?status=0"
        });
    },
    cut: function(t) {
        1 != this.data.num ? this.setData({
            num: Number(this.data.num) - 1
        }) : wx.showToast({
            title: "购买数量最小为1",
            icon: "none",
            duration: 1e3
        });
    },
    add: function(t) {
        this.setData({
            num: Number(this.data.num) + 1
        });
    },
    submit: function() {
        "1" == this.data.info.type && this.num > 1 ? wx.showToast({
            title: "直冲只支持单个购买",
            icon: "none",
            duration: 1e3
        }) : "2" != this.data.info.status ? wx.navigateTo({
            url: "/packageD/buy/myOrder_v2/myOrder_v2?tag=-2" + "&goodsId=".concat(this.data.info.goods_id, "&optionsId=&total=").concat(this.data.num, "&iscps=true&cpstype=") + this.data.info.type
        }) : wx.showToast({
            title: "商品已售罄",
            icon: "none",
            duration: 1e3
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        if (this.data.has_one_share) {
            var t = wx.getStorageSync("yz_uid"), a = "";
            return t && (a = t), {
                path: "/packageH/cpsDetail/cpsDetail?id=" + this.data.id + "&mid=" + a,
                title: this.data.has_one_share.share_desc,
                imageUrl: this.data.has_one_share.share_thumb
            };
        }
    },
    getdata: function() {
        wx.showLoading({
            title: "加载中"
        });
        var a = this, n = t.getNetAddresss("plugin.aggregation-cps.api.equity.goods-detail");
        t._getNetWork({
            url: n,
            data: {
                id: a.data.id
            },
            success: function(t) {
                var n = t.data;
                wx.hideLoading(), 1 == n.result ? a.setData({
                    info: n.data,
                    has_one_share: n.data.has_one_share
                }) : wx.showToast({
                    title: n.msg,
                    duration: 1e3,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    }
});